package com.cfun.mylearn.Support.api;

import android.os.Build;

import com.cfun.mylearn.Support.module.APISession;
import com.cfun.mylearn.Support.utils.ResourceReader;

import java.util.List;

import javax.inject.Inject;

import rx.Observable;
import rx.Scheduler;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by flyop on 19/06/2016.
 */
public class ApiAgent
{
    public static final String DAGUAN_APP_ID = "4ff4fd5cc08eb08fe5d8d74f";
    public static final String DAGUAN_APP_SECRET = "rBsUk6UhcwDQpp6btX9rVytG";
    public static final String DAGUAN_SIGNATURE_METHOD = "sha256";

    public static final String APP_VERSION = "appversion";
    public static final String APP_VERSION_CODE = "appversioncode";
    public static final String API_VERSION_KEY = "api_version";
    public static final String APP_VERSION_KEY = "app_version";
    public static final String MARKET_CHANNEL_KEY = "market-channel";
    // public static final String API_VERSION_VALUE = "13";
    // public static final String APP_VERSION_VALUE = "a-V1.1.0";

    public static final String SESSION_ID = "session_id";
    public static final String ACCOUNT_ID = "account_id";
    public static final String DEVICE_ID = "device_id";
    public static final String SIGNATURE_METHOD = "signature_method";
    public static final String SIGNATURE = "signature";
    public static final String TIMESTAMP = "timestamp";
    public static final String APP_ID = "app_id";
    public static final String RANDOM_TIME = "RANDOM_TIME";
    public static final String OS_TYPE = "os_type";
    public static final String DEVICE_TYPE = "device_type";
    public static final String DEVICE_UUID = "device_uuid";
    public static final String ANDROID_OS_TYPE = "20";
    public static final String ANDROID_DEVICE_TYPE = "10";

    @Inject
    ZheDailyApiService zheDailyApiService;

    String EMPTY_STR = "";

    Observable<List<APISession>> creatSession()
    {
//        params.setParams("device_id", "");
//        params.setParams("account_id", "");
//        params.setParams("session_id", "");
//
//        params.setParams("device_type", Build.MODEL);
//        params.setParams("os_type", "Android " + Build.VERSION.RELEASE);
//        String device_uuid = ResourceReader.getUuid();
//        // String device_uuid = ResourceReader.readUuid();
//        params.setParams("device_uuid", device_uuid);
//        params.setAppId();
//        // params.setAppVersion();
//
//        String timestamp = String.valueOf(DateTimeUtils.getCurrentTime());
//        params.setTimestamp(timestamp);
//        params.setSignature(timestamp);
//        params.setSignatureMethod();

        String timestamp = String.valueOf(DateTimeUtils.getCurrentTime());
        return zheDailyApiService.creatSession(
                EMPTY_STR,
                EMPTY_STR,
                EMPTY_STR,
                Build.MODEL,
                "Android "+Build.VERSION.RELEASE,
                ResourceReader.getUuid(),
                DAGUAN_APP_ID,
                timestamp,
                timestamp,
                DAGUAN_SIGNATURE_METHOD)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}
